import request from '@/utils/request'

/**获取萤石云用户开放平台的accessToken */
export const getEzvizAccessToken = (params: {
  appKey: string
  appSecret: string
}) =>
  request.post<{
    accessToken: string
    expireTime: number
  }>(
    'https://open.ys7.com/api/lapp/token/get',
    params,
    'application/x-www-form-urlencoded'
  )

/**添加摄像头 */
export const addCamera = (data: {
  cameraName: string
  cameraUrl: string
  appKey: string
  appSecret: string
  deviceSerial: string
  channelNo: string
  userId: string | number
}) => request.get<null>('/user/add/cameraData', data)

/**查询摄像头列表 */
export const selectCameras = (data: {userId: string | number}) =>
  request.get<Camera.Info[]>('/user/select/cameraDataList', data)

/**修改摄像头信息 */
export const editCamera = (data: {
  cameraName: string
  cameraUrl: string
  appKey: string
  appSecret: string
  cameraId: number
  deviceSerial: string
  channelNo: string
}) => request.get<null>('/user/edit/cameraData', data)

/**删除摄像头 */
export const delCamera = (data: {cameraId: number}) =>
  request.get<null>('/user/delete/cameraData', data)

/**查询单个摄像头配置信息 */
export const selectCameraData = (data: {cameraId: number | string}) =>
  request.get<Camera.Info>('/user/select/cameraData', data)
